package com.ethan.java8;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

/**
 * @author ethan
 * create 2018-08-03 上午11:37
 * desc
 **/
public class Test7 {
    public static void main(String[] args) throws ScriptException {
        //JavaScript 引擎Nashorn
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName( "JavaScript" );

        System.out.println( engine.getClass().getName() );
        System.out.println( "Result:" + engine.eval( "function f() { return 1; }; f() + 1;" ) );
    }
}
